const mongoose=require('mongoose');
const { modelName,getAlltestModel } = require('../models/testsModel');
// 获取所有试卷
async function getAlltests(req,res){
    let result=await getAlltestModel();
    res.send({
        code: 1,
        message: '试卷信息获取成功',
        result: result
    })
}
// 试卷类型获取
async function getTests(req,res){
    // console.log(req.params._id);
    let result =await mongoose.model(modelName).find({typeId:{'_id':req.body._id}}).populate('exercisesId').populate('typeId');
    // console.log(result);
    res.send({
        code: 1,
        message: '试卷类型信息获取成功',
        result: result
    })

}
// 获取一个试卷
async function getOneTest(req,res){
    let result =await mongoose.model(modelName).find({'_id':req.body._id}).populate('exercisesId').populate('typeId');
    res.send({
        code: 1,
        message: '单个试卷信息获取成功',
        result: result[0]
    })

}
 module.exports={
    getAlltests,getTests,getOneTest
}